/********************
结果汇总
* */
<template>
  <basic-container>
    <el-row>
      <targetExaminHead
        :sign="{j:true}"
      />
    </el-row>
    <el-row style="margin:25px 0 0 0 ;">
      <div :height="searchheight">
        <span style="float:right;margin-top: -30px;cursor: pointer;" @click="searchchangeadvanced">
          {{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
          <i
            :class="searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
          />
        </span>
        <div v-show="searchadvanced">
          <el-form
            :inline="true"
            :model="searchForm"
            @keyup.enter.native="getDataList()"
            class="form-inline"
          >
            <el-form-item label="姓名" v-if="!choosePerOrDept">
              <el-input v-model="searchForm.assessRealName" placeholder="姓名" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item label="部门" v-else>
              <el-input v-model="searchForm.assessDeptName" placeholder="部门" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item label="考核名称">
              <el-input v-model="searchForm.name" placeholder="考核名称" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item label="考核周期">
              <selectSearch @getDataByPerid="getDataByPerid"></selectSearch>
            </el-form-item>
            <el-form-item>
              <el-button
                icon="el-icon-search"
                type="primary"
                class="marginLeft"
                @click="getDataList(1)"
              >检索</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </el-row>
    <el-row style=" border-bottom: 1px solid #b0bde2">
     <!-- <div style="height: 50px; border-bottom: 1px solid #b0bde2">
        <div class="pull-right"><el-button type="primary">导出</el-button></div>
      </div>-->
    </el-row>
    <div style="margin:20px 0 0 0 ">
      <span>指标考核&nbsp;&nbsp;</span>
      <el-radio-group v-model="choosePerOrDept" @change="choosePerOrDeptChange">
        <el-radio :label="0">人员</el-radio>
        <el-radio :label="1">机构</el-radio>
      </el-radio-group>
    </div>
    <el-row>
      <el-table
        style="width: 100%;margin-top:20px"
        :data="dataList"
        border
        stripe
        header-align="center"
        v-loading="dataListLoading"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" header-align="center" width="55"></el-table-column>
        <el-table-column type="index" align="center" label="序号"  :index="indexMethod" width="55"></el-table-column>
        <el-table-column prop="assessUserName" align="center" label="员工编号" show-overflow-tooltip v-if="!choosePerOrDept"></el-table-column>
        <el-table-column prop="assessRealName" align="center" label="姓名" show-overflow-tooltip v-if="!choosePerOrDept"></el-table-column>
        <el-table-column prop="assessDeptName" align="center" label="部门" show-overflow-tooltip v-if="!choosePerOrDept"></el-table-column>
        <el-table-column prop="assessDeptName" align="center" label="部门" show-overflow-tooltip v-else></el-table-column>
        <el-table-column prop="name" align="center" label="考核名称" show-overflow-tooltip></el-table-column>
        <el-table-column prop="period" align="center" label="考核周期" show-overflow-tooltip></el-table-column>
        <el-table-column prop="sumScore" align="center" label="总得分" show-overflow-tooltip></el-table-column>

        <el-table-column prop="state" align="center" label="状态" show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{scope.row.appealState | transState}}</span>
          </template>
        </el-table-column>
        <!--<el-table-column fixed="right" align="center" label="操作" width="100">
          <template slot-scope="scope">
            <el-button type="primary" plain size="small" @click="dataView(scope.row)">查看</el-button>
          </template>
        </el-table-column>-->
      </el-table>
      <!--分页-->
      <div class="avue-crud__pagination">
        <el-pagination
          @size-change="sizeChangeHandle"
          @current-change="currentChangeHandle"
          :current-page="pageData.pageIndex"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageData.pageSize"
          :total="pageData.totalPage"
          background
          layout="total, sizes, prev, pager, next, jumper"
        ></el-pagination>
      </div>
    </el-row>
  </basic-container>
</template>

<script>
import targetExaminHead from "@/views/dailyExamine/components/targetExaminHead"; //状态头
import {
  resultFillList,
  resultPassOrReject,resultSummaryList
} from "@/api/dailyExamine/targetExamine/InitiateFilling";
import selectSearch from "@/views/dailyExamine/components/select-search.vue"; //流程组件

export default {
  data() {
    return {
      choosePerOrDept: 0,
      searchheight: "0", //搜索组件的高度
      searchadvanced: true, //搜索的显隐
      searchForm: {}, //搜索对象
      dataListLoading: false, //表格是否加载
      dataList: [], //表格数组
      multipleSelection: [], //勾选数据
      pageData: {
        //分页对象
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0
      }
    };
  },
  components: {
    targetExaminHead, //状态头
      selectSearch
  },
  filters: {
      transState(val) {
          switch (val) {
              case 0:
                  return "待确认";
                  break;
              case 1:
                  return "申诉中";
                  break;
              case 2:
                  return "申诉通过";
                  break;
              case 3:
                  return "申诉被驳回";
                  break;
              case 4:
                  return "已作废";
                  break;
              case 5:
                  return "已确认";
                  break;
              case 25:
                  return "已确认";
                  break;
              case 35:
                  return "已确认";
                  break;
              case 45:
                  return "已确认";
                  break;
              default:
                  break;
          }
          // 0待确认
          // 1申诉中
          // 2申诉通过
          // 3申诉被驳回
          // 4已作废
          // 5已确认
          // 25 申诉通过,已确认
          // 35 申诉被驳回,已确认
          // 45 作废,已确认
          //
          // 0 显示 确认
          // 1 隐藏 确认
          // 2 显示 确认
          // 3 显示 确认
          // 4 显示 确认
          // 5 隐藏 确认
          //
          // ssFlag   0 隐藏申诉   1显示申诉
      }
  },
  created() {
    this.getDataList();
  },
  methods: {
    choosePerOrDeptChange() {
      this.pageData.pageIndex = 1 ;
      this.searchForm = {} ;
      this.getDataList();
    },
    // 通过or驳回
    passOrRejectExamin(type) {
      // type 0是驳回 1是通过
      if (this.multipleSelection.length == 0) {
        this.$message.warning("请先选择数据");
      } else {
        let ids = this.multipleSelection.map(it => {
          return it.itemId;
        });
        resultPassOrReject(ids.toString(), type)
          .then(r => {
            if (r.data.code == 0) {
              this.$message.success("审核成功");
              this.getDataList();
            } else {
              this.$message.error(r.data.msg);
              this.getDataList();
            }
          })
          .catch(err => {});
      }
    },
    //   查看
    dataView() {},
    // 查询条件的展开关闭
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    // 查询列表
    getDataList() {
      this.dataListLoading = true ;
        resultSummaryList(
        Object.assign(
          {
            current: this.pageData.pageIndex,
            size: this.pageData.pageSize,
            type: this.choosePerOrDept
          },
          this.searchForm
        ),
        11
      )
        .then(r => {
          if (r.data.code == 0) {
            this.dataList = r.data.data.records;
            this.pageData.totalPage = r.data.data.total;
            this.dataListLoading = false ;
          }
        })
        .catch(err => {});
    },
    // 勾选数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 条数变化
    sizeChangeHandle(val) {
      this.pageData.pageIndex = 1;
      this.pageData.pageSize = val;
      this.getDataList();
    },
    // 页码分页变化
    currentChangeHandle(val) {
      this.pageData.pageIndex = val;
      this.getDataList();
    },
      //table表索引
      indexMethod(index) {
          return (this.pageData.pageIndex-1)*this.pageData.pageSize+index+1;
      },
      //选择周期执行搜索功能
      getDataByPerid(period){
          this.searchForm.period = period ;
          this.getDataList() ;
      }
  }
};
</script>

<style lang="scss" scoped>
::v-deep .el-select .el-select__tags {
  overflow: auto !important;
}
::v-deep.el-tag.el-tag--info {
  margin: 5px;
  border: 1px solid green;
}
</style>
